package vns.server.domain;

import java.util.Set;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Key;

import vns.shared.ObjectPropertyDTO;

@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable = "true")
public class ObjectProperty {
	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Key id;

	@Persistent
	private String optype;

	@Persistent
	private String objecttype;

	@Persistent
	private String name;
	@Persistent
	private boolean summary;
	@Persistent
	private boolean list;
	@Persistent
	private boolean main;
	@Persistent
	private int weight;
	@Persistent
	private boolean require;
	@Persistent
	private String describe;
	@Persistent
	private boolean readonly;
	@Persistent
	private boolean linked;
	@Persistent
	private boolean multi;

	public ObjectProperty(ObjectPropertyDTO objectPropertyDTO) {
		this.name = objectPropertyDTO.getName();
		this.summary = objectPropertyDTO.getSummary();
		this.list = objectPropertyDTO.getList();
		this.main = objectPropertyDTO.getMain();
		this.weight = objectPropertyDTO.getWeight();
		this.require = objectPropertyDTO.getRequire();
		this.describe = objectPropertyDTO.getDescribe();
		this.optype = objectPropertyDTO.getOptype();
		this.objecttype = objectPropertyDTO.getObjecttype();
		this.readonly = objectPropertyDTO.getReadonly();
		this.linked = objectPropertyDTO.getLinked();
		this.multi = objectPropertyDTO.getMulti();
	}

	public void updateFromDTO(ObjectPropertyDTO objectPropertyDTO) {
		this.name = objectPropertyDTO.getName();
		this.summary = objectPropertyDTO.getSummary();
		this.list = objectPropertyDTO.getList();
		this.main = objectPropertyDTO.getMain();
		this.weight = objectPropertyDTO.getWeight();
		this.require = objectPropertyDTO.getRequire();
		this.describe = objectPropertyDTO.getDescribe();
		this.optype = objectPropertyDTO.getOptype();
		this.objecttype = objectPropertyDTO.getObjecttype();
		this.readonly = objectPropertyDTO.getReadonly();
		this.linked = objectPropertyDTO.getLinked();
		this.multi = objectPropertyDTO.getMulti();
	}

	public ObjectPropertyDTO toDTO() {
		ObjectPropertyDTO objectPropertyDTO = new ObjectPropertyDTO(this.id,
				this.name, this.summary, this.list, this.main, this.weight,
				this.require, this.describe, this.optype, this.objecttype,
				this.readonly, this.linked, this.multi);
		return objectPropertyDTO;
	}

	public Key getid() {
		return id;
	}

	public String getOptype() {
		return optype;
	}

	public void setOptype(String optype) {
		this.optype = optype;
	}

	public String getObjecttype() {
		return objecttype;
	}

	public void setObjecttype(String objecttype) {
		this.objecttype = objecttype;
	}

	public String getName() {
		return name;
	}

	public void setName(String Name) {
		this.name = Name;
	}

	public boolean getRequire() {
		return require;
	}

	public void setRequire(boolean Require) {
		this.require = Require;
	}

	public String getDescribe() {
		return describe;
	}

	public void setDescribe(String Describe) {
		this.describe = Describe;
	}

	public boolean getSummary() {
		return summary;
	}

	public void setSummary(boolean Summary) {
		this.summary = Summary;
	}

	public boolean getList() {
		return list;
	}

	public void setList(boolean List) {
		this.list = List;
	}

	public boolean getMain() {
		return main;
	}

	public void setMain(boolean Main) {
		this.main = Main;
	}

	public int getWeight() {
		return weight;
	}

	public void setWeight(int Weight) {
		this.weight = Weight;
	}

	public void setReadonly(boolean readonly) {
		this.readonly = readonly;
	}

	public boolean isReadonly() {
		return readonly;
	}

	public void setLinked(boolean linked) {
		this.linked = linked;
	}

	public boolean isLinked() {
		return linked;
	}

	public void setMulti(boolean multi) {
		this.multi = multi;
	}

	public boolean isMulti() {
		return multi;
	}
}
